﻿package mortal.game.view.copy.escort
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;
    import mortal.game.view.task.drama.*;

    public class EscortSmallIcon extends HintBaseIcon
    {
        private static var _instance:EscortSmallIcon;

        public function EscortSmallIcon()
        {
            super(ImagesConst.guild_escort);
            this.layer = LayerManager.smallIconLayer;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseChildren = false;
            this.buttonMode = true;
            this.mouseEnabled = true;
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            var onCloseHandler:Function;
            var e:* = event;
            onCloseHandler = function (param1:int) : void
            {
                var _loc_2:IEntity = null;
                if (param1 == Alert.OK)
                {
                    if (!TaskDramaOperator.isInFlyDrama)
                    {
                        _loc_2 = ThingUtil.entityUtil.getSelfEscortEntity();
                        if (_loc_2)
                        {
                            AIManager.cancelAll();
                            AIManager.addMoveToOtherMap(MapFileUtil.mapID, MapFileUtil.mapID, new Point(_loc_2.x2d, _loc_2.y2d), 0);
                            AIManager.start();
                        }
                        else
                        {
                            GameProxy.task.getEscortInfoPos();
                        }
                    }
                }
                return;
            }// end function
            ;
            Alert.mode = Alert.Mode_NoneNotModal;
            Alert.buttonWidth = 70;
            Alert.timerOut = 5;
            Alert.okLabel = Language.getString(35210);
            var alertWin:* = Alert.show(Language.getString(35211), null, Alert.OK, null, onCloseHandler);
            return;
        }// end function

        public static function get instance() : EscortSmallIcon
        {
            if (!_instance)
            {
                _instance = new EscortSmallIcon;
            }
            return _instance;
        }// end function

    }
}
